﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CSharp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
       
        DianChi changHong = null;
        private void btnCreateChanghong_Click(object sender, EventArgs e)
        { 
            //创建电池对象
            changHong = new DianChi();
            //能够存储对象(类型)数据的变量名叫：字段
            changHong.dianYa = 9;//电压
            changHong.mingZi = "长虹电池";
            changHong.youXiaoQi = DateTime.Now;
            Console.WriteLine(changHong);
            MessageBox.Show("changHong是什么东西？" + changHong.ToString());
            MessageBox.Show("changHong的电压:" + changHong.dianYa);
            MessageBox.Show("changHong的名字:" + changHong.mingZi);
            MessageBox.Show("changHong的日期:" + changHong.youXiaoQi.ToString());
        }

        private void btnCreatePhone_Click(object sender, EventArgs e)
        {
            //创建一个“诺基亚”手机
            TelePhone nokia = new TelePhone();
            nokia.brand = "诺基亚"; //字段只能赋值和使用
            nokia.name = "砸核桃专用机";
            nokia.price = 599;
            nokia.battery = changHong;

            //nokia.AboutMe();//方法只能调用
            nokia.PowerOn();//开机
        }

        private void button1_Click(object sender, EventArgs e)
        {
            changHong.dianLiang = 100;//充电
        }
    }
}
